/**
 * Created by QIAODI on 8/24/2016.
 */
const mongoose = require("mongoose");
const request = require("request");
const async = require('async');
var Dish = mongoose.model("dish");

exports.queryDish = function (req, res) {
    var dids = JSON.parse(req.body.dids);
    var dishDetails = {};

    async.each(dids, function (did, callback) {
        Dish.findOne({_id: did})
            .populate('merchant')
            .exec(function (err, dish) {
                if (!err) {
                    dishDetails[did] = dish;
                    callback();
                }
                else {
                    res.json({error: "queryDish"});
                }
            });
    }, function (err) {
        console.log(dishDetails);
        res.json(dishDetails);
    });
}
